package com.example.towSpringBoot.mapper;


import com.example.towSpringBoot.dto.DepartmentDto;
import com.example.towSpringBoot.entity.Department;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author xinTong
 * @since 2024-01-23
 */
public interface DepartmentMapper{

    /**
     * 查询部门信息
     * @param pageNum
     * @param pageSize
     * @return
     */
    @Select("select * from rbac.department")
    Page<Department> query();

    /**
     * 删除部门
     * @param id
     */
    @Delete("delete from rbac.department where id=#{id}")
    void delete(Long id);

    /**
     * 查询指定部门
     * @param id
     * @return
     */
    @Select("select * from rbac.department where id = #{id}")
    DepartmentDto info(Long id);

    /**
     * 修改
     * @param departmentDto
     */
    void update(DepartmentDto departmentDto);

    /**
     * 新增
     * @param departmentDto
     */
    @Insert("insert into rbac.department (name, sn) values (#{name}, #{sn})")
    void save(DepartmentDto departmentDto);

    /**
     * 查询所有部门
     * @return
     */
    @Select("select * from rbac.department")
    List<Department> listAll();

    /**
     * 总数
     * @return
     */
    @Select("select count(*) from rbac.department")
    int count();
}
